package com.qf.day09.work1;

import java.util.Scanner;

public class Menu {
    public void show(){
        Scanner scanner = new Scanner(System.in);
        UserService userService = new UserServiceImpl();

        while(true){
            System.out.println("请输入你的选择： 1，注册 2.登录 3.退出");
            String select = scanner.next();
            switch (select){
                case "1":
                    System.out.println("请输入注册用户名");
                    String userName = scanner.next();
                    System.out.println("请输入注册密码");
                    String password = scanner.next();
                    boolean flag = userService.register(userName , password);
                    if(flag){
                        System.out.println("注册成功");
                    }else {
                        System.out.println("注册用户名重复");
                    }

                    break;
                case "2":
                    System.out.println("请输登录入用户名");
                    String loginUserName = scanner.next();
                    System.out.println("请输登录入密码");
                    String loginPassword = scanner.next();
                    boolean loginFlag =  userService.login(loginUserName,loginPassword);
                    if(loginFlag){
                        System.out.println("登录成功");
                    }else {
                        System.out.println("登录失败用户名或密码错误");
                    }
                    break;
                case "3":
                    System.out.println("退出啦！！！");
                default:
                    System.out.println("输入错误重新输入");
                    break;
            }
        }
    }

}
